package memorphic.slide.plugin.generators;

 public class ContextTemplate extends SlideBaseTemplate
 {

 	
  protected static String nl;
  public static synchronized ContextTemplate create(String lineSeparator)
  {
    nl = lineSeparator;
    ContextTemplate result = new ContextTemplate();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = NL + "package ";
  protected final String TEXT_2 = NL + "{" + NL + "\timport memorphic.slide.FeatureContextBase;" + NL + "\t" + NL + "\tpublic class ";
  protected final String TEXT_3 = " extends FeatureContextBase" + NL + "\t{" + NL + "" + NL + "\t\tpublic static const FEATURE_ID:String = \"";
  protected final String TEXT_4 = "\";" + NL + "\t\t" + NL + "\t\t" + NL + "\t\tpublic const states:";
  protected final String TEXT_5 = "  = new ";
  protected final String TEXT_6 = "();" + NL + "" + NL + "\t\tprivate var controller:";
  protected final String TEXT_7 = ";" + NL + "" + NL + "\t\t/**" + NL + "\t\t * " + NL + "\t\t * " + NL + "\t\t */" + NL + "\t\tpublic function ";
  protected final String TEXT_8 = "()" + NL + "\t\t{" + NL + "\t\t\tsuper();" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t" + NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * " + NL + "\t\t * Creates the primary instance of this Feature Context. Each view has it's own instance of the Context, whose" + NL + "\t\t * properties are bound to the primary instance's properties." + NL + "\t\t * " + NL + "\t\t */" + NL + "\t\tprotected override function createPrimaryInstance():IFeatureContext" + NL + "\t\t{" + NL + "\t\t\treturn new ";
  protected final String TEXT_9 = "();" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t" + NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t * " + NL + "\t\t * The unique id of this feature" + NL + "\t\t * " + NL + "\t\t */\t\t" + NL + "\t\tpublic override function get featureId():String" + NL + "\t\t{" + NL + "\t\t\treturn FEATURE_ID;" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t" + NL + "\t\t" + NL + "\t\t/**" + NL + "\t\t *\tCalled automatically on the Feature's primary instance, to initialize it. " + NL + "\t\t * " + NL + "\t\t */\t\t" + NL + "\t\tprotected override function initFeature():void" + NL + "\t\t{" + NL + "\t\t\t" + NL + "\t\t\t// Create Presentation Models" + NL + "\t\t\t" + NL + "\t\t\t// Create State Manager" + NL + "\t\t\tstateManager = new StateManager();" + NL + "\t\t\t" + NL + "\t\t\t" + NL + "\t\t\t// Create Controller" + NL + "\t\t\tcontroller = new ";
  protected final String TEXT_10 = "(this);" + NL + "\t\t}" + NL + "\t}" + NL + "}";

/* (non-javadoc)
    * @see IGenerator#generate(Object)
    */
public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
    stringBuffer.append( featurePackage );
    stringBuffer.append(TEXT_2);
    stringBuffer.append( contextClassName );
    stringBuffer.append(TEXT_3);
    stringBuffer.append( featureID );
    stringBuffer.append(TEXT_4);
    stringBuffer.append( stateClassName );
    stringBuffer.append(TEXT_5);
    stringBuffer.append( stateClassName );
    stringBuffer.append(TEXT_6);
    stringBuffer.append( controllerClassName );
    stringBuffer.append(TEXT_7);
    stringBuffer.append( contextClassName );
    stringBuffer.append(TEXT_8);
    stringBuffer.append( contextClassName );
    stringBuffer.append(TEXT_9);
    stringBuffer.append( controllerClassName );
    stringBuffer.append(TEXT_10);
    return stringBuffer.toString();
  }
}